﻿<!DOCTYPE html>
<html>

	<head>
		<meta charset="UTF-8">
		<title>MySearch</title>
		<meta content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=0" name="viewport" />
		<link rel="stylesheet" type="text/css" href="css/bootstrap.min.css" />
		<style type="text/css">
			body {
				overflow: visible;
				padding-top: 100px;
				padding-bottom: 70px;
			}
			
			button{
				margin-top: 5px;
			}				
			
			.ad {
				width: 300px;
				margin: 0 auto;				
			}
			.suggest{
				    position: absolute;
    				display: none;
			}
			.suggest-search{
				position:absolute;top:45px;left:0px;z-index:999;*z-index:555;width:100%;font-family:Arial,"PingFang SC",Helvetica,"Microsoft YaHei",SimSun;box-shadow:0 0 5px 0 rgba(0,0,0,.2);background-color:#fff;background-color: white;
			}
			.suggest-search .list-hook{
			    padding-bottom: 1px;
    			zoom: 1;
			}
			ol, ul, dl{
				list-style: none;
				padding: 0px;
			}
			.suggest-search .suggest-item{
				padding: 2px 0 2px 9px;
			    font: 14px \5B8B\4F53;
			    height: 24px;
			    line-height: 24px;
			    position: relative;
			    
			    color: #333;
			    font-size: 14px;
			    height: 26px;
			    padding-left: 16px;
			    line-height: 26px;
			    text-align: left;
			    cursor: pointer;
			}
			.suggest li.hover{
				background-color: #f5f5f5;
			}
		</style>
		<link rel="icon" href="img/search_cat_32px.png" />
		<link rel="icon" href="img/search_cat_72px.png"" sizes="72x72" />
		<link rel="apple-touch-icon-precomposed" href="img/search_cat_72px.png"" />
		<meta name="msapplication-TileImage" content="img/search_cat_72px.png"" />
		
	</head>
	<body>
		<div class="container">
			<div class="row clearfix">
				<div class="col-md-12 column">
					<nav class="navbar navbar-default navbar-fixed-top" role="navigation">
						<div class="container">
							<!-- Brand and toggle get grouped for better mobile display -->
							<div class="navbar-header">
								<button type="button" class="navbar-toggle collapsed" data-toggle="collapse" data-target="#bs-example-navbar-collapse-1">
        							<span class="sr-only">Toggle navigation</span>
        							<span class="icon-bar"></span>
        							<span class="icon-bar"></span>
        							<span class="icon-bar"></span>
      							</button>
								<a class="navbar-brand" href="../index/cn/">精品网站</a>
							</div>
							<!-- Collect the nav links, forms, and other content for toggling -->
							<div class="collapse navbar-collapse" id="bs-example-navbar-collapse-1">
								<ul class="nav navbar-nav">
									<li class="active">
										<a href="http://yunmi.ren:8080/CollectWeb/manage/search/">搜索</a>
									</li>
								</ul>		
								
								
								<form class="navbar-form navbar-right" role="search" autocomplete="off">
									
									<div class="form-group">	
							          <label  for="inIframe">内嵌页打开</label>
									  <input id="inIframe" type="checkbox"  />
									  &nbsp;&nbsp;
							          <label  for="inNew">在新窗口中打开</label>
									  <input id="inNew" type="checkbox"  />
									  &nbsp;&nbsp;
							        </div>
							        <div class="form-group">	
							          <label  for="searchselect">默认搜索引擎</label>
									  <select id="searchselect" onchange="" class="form-control">							  
										  <option value="baidu">百度</option>
										  <option value="google">谷歌</option>
										  <option value="sogou">搜狗</option>
										  <option value="bing">必应</option>
										  <option value="googlem">谷歌镜像</option>
									  </select>
							        </div>							        
							     </form>
								<p class="navbar-text navbar-right">
								<a href="../index/cn/about.html" class="navbar-link" title="">关于本站</a>
				</p>
								
							</div>
							<!-- /.navbar-collapse -->
						</div>
						<!-- /.container-fluid -->
					</nav>
					<div class="jumbotron text-center" style="background: transparent; height: 150px;">
						<h1><small><b>MySearch</b> tb.inc</small></h1>
						
					</div>
				</div>
				<form onsubmit="return false">
				<div class="row clearfix">
					<div class="col-md-2 column">
					</div>
					<div class="col-md-8 column text-center" style="margin: 5px;5px;5px;5px;">
						<div class="form-group" style="position: relative;">
							<input type="text" class="form-control  input-lg" autoComplete="off" placeholder="输入要搜索的内容" id="content" name="content" />
							<div class="suggest suggest-search g-bg11 g-br9" style="display: none;">
								<div class="header-hook detail"></div>
								<ul class="list-hook" style="height: auto;">
									
<!-- 								<li class="suggest-item item-hook sug-input" data-query="aabc" data-index="1" data-data="null"><span class="suggest-text"><b>a</b>abc</span><span class="tag-type hide" data-history="hide" data-hooks="hide" data-suez="">推荐</span></li> -->
								</ul>
								<div class="footer-hook" style="display: none;">
								<a href="javascript:;" monkey="history" class="fr" data-hooks="close-history-sug">关闭</a><a href="javascript:;" monkey="history" class="fl" data-hooks="close-history">关闭历史</a>
								</div>
							</div>
						</div>
					</div>
					<div class="col-md-2 column">
					</div>
				</div>
				<div class="row clearfix">
					<div class="col-md-12 column text-center">
						<div id="searchTool">
							<button type="button" id="baidu" data-url="http://www.baidu.com/s?wd=${search}" class="btn btn-primary">百度</button>
							<button type="button" id="baidu_fy" data-url="https://fanyi.baidu.com/?aldtype=85#en/zh/${search}" class="btn btn-warning">翻译</button>
							<!--<button type="button" id="google" data-url="http://www.google.com/search?q=${search}" class="btn btn-info">谷歌</button>-->
							<button type="button" id="google" data-url="http://www.baidu.com/s?wd=物流单号查询 ${search}" class="btn btn-info">运单</button>
							<button type="button" id="sogou" data-url="https://www.sogou.com/web?query=${search}" class="btn btn-danger">搜狗</button>
							<button type="button" id="bing" data-url="http://cn.bing.com/search?q=${search}" class="btn btn-success">必应</button>
							<button type="button" id="zhihu" data-url="https://minecraft-zh.gamepedia.com/${search}" class="btn btn-info">知乎</button>							
							<button type="button" id="panc" data-url="http://www.panc.cc/s/${search}/td_0" class="btn btn-primary">网盘</button>
							<button type="button" id="minecraft" data-url="https://minecraft-zh.gamepedia.com/${search}" class="btn btn-success">Minecraft</button>
							<button type="button" id="jd" data-url="http://search.jd.com/Search?enc=utf-8&keyword=${search}" class="btn btn-danger">京东</button>
							<button type="button" id="taobao" data-url="https://s.taobao.com/search?q=${search}" class="btn btn-warning">淘宝</button>
							<button type="button" id="seed" data-url="https://torrentz2.eu/search?f=${search}" class="btn btn-info">种子</button>
							
						</div>
					</div>
					<div class="col-md-12 column text-center"  style="margin-top: 20px;">
							<div>常用工具</div>
					</div>
					<div class="col-md-12 column text-center">
						<div id="searchTool">
							<button type="button" id="baidu" data-url="/FavWeb/manage/json/json.html" class="btn btn-primary">JSON解析</button>
							<button type="button" id="baidu" data-url="https://tool.oschina.net/" class="btn btn-primary">Web工具</button>
							<button type="button" id="baidu" data-url="/FavWeb/manage/cron/cron.html" class="btn btn-primary">Cron表达式</button>
							
						</div>
					</div>
					<div class="col-md-12 column text-center"  style="margin-top: 20px;">
							<div>我的TODO</div>
					</div>
					<div class="col-md-12 column text-center">
						<div id="searchTool">
							<button type="button" id="baidu" data-url="http://172.16.2.201:8100/login.html" class="btn btn-primary">汉王</button>
							<button type="button" id="baidu" data-url="http://172.16.2.101/" class="btn btn-primary">日报</button>
							<button type="button" id="baidu" data-url="http://192.168.0.109:8888/zentaopms" class="btn btn-primary">禅道</button>
							<button type="button" id="baidu" data-url="http://172.16.254.44:9000" class="btn btn-primary">容器</button>
							
						</div>
					</div>
				</div>				
				</form>
				
			</div>
		</div>
		<div style="text-align: center;color: #ccc;position: fixed;bottom: 0px;width: 100%;">
			<p><a href="http://icp.chinaz.com/info?q=yunmi.ren">	渝ICP备19010959号-1</a></p>
		</div>
		
		<script src="js/jquery-3.1.1.min.js" type="text/javascript" charset="utf-8"></script>
		<script src="js/bootstrap.min.js" type="text/javascript" charset="utf-8"></script>
        <script type="text/javascript">
        		$("#content").focus();
                var content = "";
                var inNew = getCookie("inNew");
                var inIframe = getCookie("inIframe");
                var searcher = getCookie("searcher");
                $(document).ready(function () {
                    //默认搜索引擎
                    if (searcher == "") {
                        setSearcher("baidu");
                    } else {
                        setSearcher(searcher);
                    }

                    //是否在新窗口打开
                    if (inNew != "") {
                        if (inNew == "true") {
                            $("#inNew").attr("checked", "true");
                        } else {
                            $("#inNew").removeAttr("checked");
                        }
                    }
                    setInNew();
                    //是否在内嵌页打开
                    if (inIframe != "") {
                        if (inIframe == "true") {
                            $("#inIframe").attr("checked", "true");
                        } else {
                            $("#inIframe").removeAttr("checked");
                        }
                    }
                    setInIframe();
                });
                $("body").click(function(){
                	$(".suggest").hide();
                });
				$("#content").bind('input propertychange',function(){
					var val=$("#content").val();
					$.ajax({
						url: 'https://www.baidu.com/sugrec?prod=pc_hao123&wd='+val+'&pre=1&p=3&ie=utf-8&json=1&from=pc_hao123',
						dataType: "jsonp" 
					}).done(function(a,b){
						var c="";
						if(a.g && a.g.length >0 ){ 
							$.each(a.g,function(a1,b1){
								c=c+'<li class="suggest-item item-hook sug-input"  data-r='+b1.q+'><span class="suggest-text">'+b1.q+'</span></li>';
							});
							$(".list-hook").html(c);
							$(".suggest").show();
						}
						$(".suggest-item").hover(function(){
							$(".suggest-item").removeClass("hover");
							$(this).addClass("hover");
						},function(){
							$(this).removeClass("hover");
						});
						
						$(".suggest-item").click(function(){
							$("#content").val($(this).attr("data-r"));
// 							alert($(this).attr("data-r"));  
// 							setTimeout(function(){
								
// 							},1000);
							$(".suggest").hide();
							
						});
					});
				})
                $("#searchselect").change(function () {
                    setSearcher($("#searchselect").val());
                })

                $("#inNew").change(function () {
                    setInNew();
                })
                 $("#inIframe").change(function () {
                	 setInIframe();
                })

                $("#content").keypress(function (event) {
                    if (event.keyCode == '13') {
                        $("#" + searcher).trigger("click");
                    }
                });
				
                $("#searchTool button").click(function(){
                	getcontent();
                	var $obj=$(this);
                	var url=$obj.attr("data-url");
                	url=url.replace("${search}",content);
                	if(inIframe){
                		url="./result.html?"+url;
                	}
                	window.open(url, inNew);
                });


                //获取url中的参数
                function getUrlParam(name) {
                    var reg = new RegExp("(^|&)" + name + "=([^&]*)(&|$)");
                    var r = window.location.search.substr(1).match(reg);
                    if (r != null) return decodeURI(r[2]); return null;
                }
                //获取输入框内容
                function getcontent() {
                    content = encodeURIComponent($("#content").val());
                }

                //设置名为cname值为cvalue存活期为exdays天的cookie
                function setCookie(cname, cvalue, exdays) {
                    var d = new Date();
                    d.setTime(d.getTime() + (exdays * 24 * 60 * 60 * 1000));
                    var expires = "expires=" + d.toGMTString();
                    document.cookie = cname + "=" + cvalue + "; " + expires;
                }

                //获取名为cname的cookie值
                function getCookie(cname) {
                    var name = cname + "=";
                    var ca = document.cookie.split(';');
                    for (var i = 0; i < ca.length; i++) {
                        var c = ca[i].trim();
                        if (c.indexOf(name) == 0) return c.substring(name.length, c.length);
                    }
                    return "";
                }


                //设定是否在新窗口中打开
                function setInNew() {
                    setCookie("inNew", $("#inNew").is(':checked'), 30);
                    inNew = $("#inNew").is(':checked') ? "_blank" : "_self";
                }
                function setInIframe() {
                    setCookie("inIframe", $("#inIframe").is(':checked'), 30);
                    inIframe = $("#inIframe").is(':checked') ;
                }

                //设置默认搜索引擎
                function setSearcher(value) {
                    searcher = value;
                    $("#searchselect").val(value);
                    setCookie("searcher", value, 30);
                }
        </script>

	</body>


	
</html>
